package com.yang.bean.beanDefinition;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: bean标签对应的对象, 可以用多个property标签
 * @author: Yang Qiang
 * @create: 2021-11-07 16:55
 */
public class BeanDefinition {
    // 单例对应的常量
    private static final String SCOPE_SINGLETON = "singleton";
    // 原型对应的常量
    private static final String SCOPE_PROTOTYPE = "prototype";

    // bean对应的名字
    private String beanName;

    // class对应的名字
    private String className;

    // bean是单例还是原型
    private String scope;

    // bean的多个属性
    private List<PropertyValue> propertyValues = new ArrayList<>();

    /**
     * 添加bean的property属性
     * @param propertyValue: 对应的property标签
     */
    public void addProperty(PropertyValue propertyValue){
        this.propertyValues.add(propertyValue);
    }
    /**
     * 判断bean是不是单例
     * @return
     */
    public boolean isSingleton(){
        return SCOPE_SINGLETON.equals(this.scope);
    }
    /**
     * 判断bean是不是原型
     * @return
     */
    public boolean isPrototype(){
        return SCOPE_PROTOTYPE.equals(this.scope);
    }

    public BeanDefinition() {
    }

    public BeanDefinition(String beanName, String className) {
        this.beanName = beanName;
        this.className = className;
    }

    public BeanDefinition(String beanName, String className, String scope, List<PropertyValue> propertyValues) {
        this.beanName = beanName;
        this.className = className;
        this.scope = scope;
        this.propertyValues = propertyValues;
    }

    public static String getScopeSingleton() {
        return SCOPE_SINGLETON;
    }

    public static String getScopePrototype() {
        return SCOPE_PROTOTYPE;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public List<PropertyValue> getPropertyValues() {
        return propertyValues;
    }

    public void setPropertyValues(List<PropertyValue> propertyValues) {
        this.propertyValues = propertyValues;
    }
}
